Hit testing is a technology frequently used in a computer development (for example, game program development) process. It is used to determine whether a cursor (such as a mouse cursor or touch-point on a touch-screen interface) controlled by a user intersects a given object (such as a shape, line, or curve) on the screen. Generally, hit testing occupies quite a lot of central processing unit (CPU) resources, and therefore a quicker execution process of the hit testing is expected.
In the existing hit testing technology, a hit testing area of a rendered object in a scenario is pre-designed, where the hit testing area usually has a rectangular border. When a touch or hit event occurs in a rendered object list, hit testing determination is performed on each rendered object in the rendered object list in sequence, which is generally to determine whether a coordinate value of the touch or hit event is within a preset hit testing area of the object. If it is determined that a coordinate value of a touch or hit event is within a preset hit testing area of a certain object, an identifier (ID) value of the object is returned. In addition, when rendered objects overlap, a front-back layered relationship of the bodies needs to be considered. Before determination, it is first required to perform ranking of the objects or construct a parent-child tree structure for objects in the scenario, then the hit testing is performed from front to back, and an ID of a first successfully determined object is returned.
In the existing hit testing technology, by pre-designing the hit testing area, the profile contour of the object can be roughly simulated. However, when an object has an irregular profile and an ideal and precise hit testing result is expected, many formulas need to be introduced to define the profile, and sometimes the object profile cannot be precisely described by designing the hit testing area. In this case, it is difficult to precisely execute a hit testing for an irregular object. Moreover, during the hit testing, the more complicated the hit testing area of the object is, the more computer resources are consumed. Therefore, the hit testing technology in the prior art also occupies a large amount of computer resources.
In addition, in the existing hit testing technology, when a body profile is changed, and particularly when an irregular body profile is changed, it is difficult to update the hit testing area in time, making the hit testing result inaccurate.